some basic algorithms.