identation fixed
refactoring, moving few things round a bit