Build and find class functions seem to work but gives wrong output