small refactoring - still not working properly