refactored with ids..almost working now