generalized the expand pizel method
mereged but bug remains from pulled code