Small bug fix, has to be refactored