made code clean and updated test