moving the code into proper modules