Implemented preSelect(), refactored the code to work with preSelect()