some basic refactoring
minor refactoring to suit environment