functional version of code after pagemin debug