some code cleaned up