code cleaned, comments added