refactored deinterlace code