add the code for direct calculation