code clean up and fixed indentation