bug fixes + added abstraction