whitespace, cleanup
refactored duplicated code
removed unused entity field