organised code to make it clearer