Modularised code. Removed callback hells