As mentioned in the comments, your main problem is you declare starttime as an int. This is a signed value with a range of -32,768 to 32,767. You will quickly overflow - in about 32 seconds.
The solution is to use an unsigned long which has a range of 0 to 4,294,967,295.