simplify and remove unused code