wrote stuff in algorithm