Added some functions, bugs removed and corrected time loop