Modified version of CE1

divide functions into different methods