First (buggy) implementation