Refactoring code
Further code cefactoring.