refactor code. Added new methods