cleaning up code
optimize on enter and major refactor