refactoring and working on scheme