Implemented all logic