added all required functionality & tests