First iteration (main functionality untested)