Fixed problem with pitch algorithm