added all logic