Timeout function semi working