better code - thanks @adwhit