implemented remove, checking for dependencies