made some changes to reorganise the code