sub-routine working now