Fixed spec
Fixed missed variable
Fixed duplicated code
Fixed unused variable