Simplified the code per Julen's sugestion