fixed timezone bug, cleaned up code