Implemented JC-1503
-refactor some code