Write helper functions and general plan