logic
fixed error/made recursive