cleaning up the code in cycle js