Refactoring. Used more clean js objects