implement basic algorithms