added nouce calculation