Fixed #1, previous fix was buggy