Moved code to definitions. Timer added