add helper function
thanks for the fixes @alesj