Fixed wrong indentation, removed useless condition check
Refactoring and style fixes