refactors, all the main features implemented