moved logic to seperate files