easy readable algorithm