cleaned code and added citation