a bit of refactoring for nicer look