refracted some code. Using wordpress