Fixed indentation and little bit of refactoring