updated code with array capable of handling decimals
updated with array to handle decimals