removal of unused vars, shortening of existing code